Skip to content

fix(composer): preserve quote focus on iOS devices#532

Open
vforsh wants to merge 2 commits intoDimillian:mainfrom
vforsh:fix/ios-quote-focus
Open

fix(composer): preserve quote focus on iOS devices#532
vforsh wants to merge 2 commits intoDimillian:mainfrom
vforsh:fix/ios-quote-focus

Conversation

@vforsh
Copy link
Contributor

@vforsh vforsh commented Mar 1, 2026

Summary

  • fix composer quote insertion to focus the textarea immediately in the click gesture
  • keep the existing requestAnimationFrame focus pass to re-apply caret position after state update
  • add a regression test covering immediate focus + RAF caret reapply

Problem

On real iOS devices, tapping Quote message inserted text but often did not move focus/caret into the composer. The simulator allowed it, but physical Safari/WebKit can reject delayed focus that is no longer tied to the original user gesture.

Fix

  • call focus() + setSelectionRange() synchronously inside useComposerInsert before state update
  • keep a second focus/caret application in requestAnimationFrame to preserve final cursor placement after render

Validation

  • npm run test -- src/features/app/hooks/useComposerInsert.test.tsx
  • npm run typecheck

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca24fc76f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +463 to +467
onMouseDown={() => {
selectionSnapshotRef.current = getSelectedMessageText();
}}
onTouchStart={() => {
selectionSnapshotRef.current = getSelectedMessageText();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid overwriting touch selection snapshot on mousedown

On touch browsers that emit compatibility mouse events (notably iOS Safari and many Android WebViews), onTouchStart can capture the highlighted fragment, but the later synthetic onMouseDown on the same button may run after the selection has collapsed and overwrite selectionSnapshotRef with null; handleQuote then quotes the full message instead of the selected fragment. This makes touch-based fragment quoting unreliable specifically in those environments.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant